/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package caintra.Sapra.ComponentsImplements;

import java.text.DecimalFormat;
import nextapp.echo2.app.Alignment;
import nextapp.echo2.app.Color;
import nextapp.echo2.app.Component;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.Font;
import nextapp.echo2.app.Label;
import nextapp.echo2.app.Table;
import nextapp.echo2.app.layout.TableLayoutData;
import nextapp.echo2.app.table.DefaultTableCellRenderer;
import nextapp.echo2.app.table.TableCellRenderer;

/**
 *
 * @author Administrador
 */
public class BodyTableCaintra extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){

        String txt="";
        if(value!=null)
            txt=value.toString();
        else
            txt="";
        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();

        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 1:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 2:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 3:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 4:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 5:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 6:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 7:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 8:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 9:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 10:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 11:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 12:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 13:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 14:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 15:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 16:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
        }
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(9)));

        return label;
    }
}

class BodyDetailTableCaintra extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){

        String txt="";
        if(value!=null)
            txt=value.toString();
        else
            txt="";

        formato_decimal.setMinimumFractionDigits(2);//set cantidad minima de digitos en conversion
        formato_decimal.setMaximumFractionDigits(2);

        if(column >= 4){
            try {
                txt=formato_decimal.format(Double.parseDouble(txt));
                txt="$ "+txt;
            } catch (Exception e) {
                txt="$ 0.00";
            }

        }

        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();
        if(row%2==0)
            tld.setBackground(Color.WHITE);//175 238 238
        else
            tld.setBackground(new Color(175,238,238));//175 238 238

        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 1:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 2:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 3:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 4:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 5:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 6:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 7:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 8:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 9:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
            case 10:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;

        }
        label.setForeground(Color.BLACK);
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(9)));
        return label;
    }
}
class TotalTableCaintra extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){
        String txt="";
        if(value!=null)
            txt=value.toString();
        else
            txt="";


        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();

        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 1:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
        }
        label.setForeground(Color.BLACK);
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(9)));

        return label;
    }
}
class BodyAjusteTableCaintra extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){

        String txt="";
        if(value!=null)
            txt=value.toString();
        else
            txt="";


        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();

        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_LEFT);break;
            case 1:tld.setAlignment(Alignment.ALIGN_LEFT);break;
            case 2:tld.setAlignment(Alignment.ALIGN_LEFT);break;
            case 3:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);
            case 4:tld.setAlignment(Alignment.ALIGN_LEFT);break;
        }
        label.setForeground(Color.BLACK);
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(9)));
        return label;
    }
}


class DispersionTable extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){
        String txt="";
        if(value!=null)
            txt=value.toString();
        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();
        if(row%2==0)
            tld.setBackground(Color.WHITE);//175 238 238
        else
            tld.setBackground(new Color(175,238,238));//175 238 238
        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 1:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
        }


        label.setForeground(Color.BLACK);
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(11)));
        return label;
    }



}

class CuentaCaintra extends DefaultTableCellRenderer implements TableCellRenderer{

    public DecimalFormat formato_decimal = new DecimalFormat("#########.##");
@Override
    public Component getTableCellRendererComponent(Table table,Object value,int column,int row){
        String txt="";
        if(value!=null)
            txt=value.toString();
        else
            txt="";


        Label label=new Label(txt);
        TableLayoutData tld=new TableLayoutData();

        switch(column){
            case 0:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 1:tld.setAlignment(Alignment.ALIGN_LEFT);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            case 2:tld.setAlignment(Alignment.ALIGN_CENTER);tld.setBackground(new Color(244,244,254));label.setForeground(Color.BLACK);break;
            
            case 3:tld.setAlignment(Alignment.ALIGN_RIGHT);tld.setBackground(new Color(209,207,207));label.setForeground(Color.BLACK);break;
        }
        label.setForeground(Color.BLACK);
        label.setLayoutData(tld);
        label.setFont(new Font(Font.ARIAL, 1, new Extent(9)));

        return label;
    }
}